23 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
24 #define For(i, a, b) for (int i=(a); i<(b); ++i)
25 #define D(x) cout << #x " is " << x << endl
28 int x1
, times
, position
;
29 while (cin
>> x1
>> times
>> position
) {
30 if (x1
== 0 and times
== 0 and position
== 0) break;
32 while (x1
> 0) v
.push_back(x1
% 10), x1
/= 10;
33 reverse(v
.begin(), v
.end());
35 //printf("V is "); For(i, 0, v.size()) printf("%d ", v[i]); puts("");
37 for (int t
= 0; t
< times
- 1; ++t
) {
40 for (int i
= 0; i
< v
.size(); ) {
42 while (j
< v
.size() and v
[i
] == v
[j
]) j
++;
44 //printf("%d appears %d times from [%d,%d)\n", v[i], size, i, j);
46 while (size
> 0) w
.push_back(size
% 10), size
/= 10;
47 reverse(w
.begin() + n
, w
.end());
50 if (w
.size() > 3000) break;
55 //printf("V is "); For(i, 0, v.size()) printf("%d ", v[i]); puts("");
57 cout
<< v
[position
- 1] << endl
;